<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style type="text/css">
        *{margin: 0;padding: 0;font-size: 16px;}
        table{width: 100%;border-spacing: 0;}
        th,td{font-weight: normal;border: 0;text-align: center;line-height: 40px;border-right: 1px solid #000000;border-bottom: 1px solid #000000;}
        th{width: 12%;}
        td{width: 13%;padding: 5px;}
        table tr:last-child th,table tr:last-child td{border-bottom: 0;}
        tr td:last-child{border-right: 0;}
        table input[type="text"]{width: 100%;height: 100%;border: 0;outline: 0;display: block;text-align: center;}
        table input[type="number"]{width: 100px;text-align: center;outline: 0;-webkit-appearance:button;}
        textarea{width: 100%;height: 100%;border: 0;outline: 0;display: block;resize: none;}
        .apply_image{width: 50px;height: 50px;display: block;float: left;}
        .layui-upload-list input{display: none;}
        #submit{width: 60px;height: 30px;line-height: 30px;text-align:center;color: #ffffff;background: #ff5555;border-radius: 5px;border: 0;margin: 20px auto;outline: 0;display: block;cursor: pointer;}
    </style>
</head>
<body>
<div style="padding: 20px 0;">
    <form class="layui-form " action="">

        <!--<header style="width: 90%;overflow: hidden;margin: 0 auto;">-->
            <!--<span style="float: left;font-weight: bold;">编号：<input style="width: 100px;border: 0;outline: 0;" type="text" name="base[no]" /></span>-->
            <!--<span style="float: right;">介绍人：<input style="width: 100px;border: 0;outline: 0;" type="text" name="base[parent_no]" value="{$userInfo.parent_no}" readonly/></span>-->
        <!--</header>-->
        <!--<div style="width: 90%;overflow: hidden;margin: 10px auto;">-->
            <!--日期：<input style="width: 200px;border: 0;outline: 0;" type="datetime-local" name="base[date]" />-->
        <!--</div>-->
        <div style="width: 90%;text-align: center;line-height: 50px;font-size: 20px;margin: 5x auto;font-weight: bold;">和盛堂食疗体验服务表</div>
        <table border="1px solid #000000" cellspacing="" cellpadding="" style="width: 90%;margin: 0 auto;"  id="basicmessage">
            <tr>
                <th colspan="8" style="border-right: 0;text-align: left;font-weight: bold;background: #aae0fa;text-indent: 10px;">基本信息</th>
                <!--<td colspan="7"></td>-->
            </tr>
            <tr>
                <th>姓名</th>
                <td><input type="text" name="base[name]" lay-verify="base[name]" value="{$userInfo.name}"/></td>
                <th>年龄</th>
                <td><input type="text" name="base[age]" lay-verify="base[age]" value="{$userInfo.age}"/></td>
                <th>性别</th>
                <td>
                    <input type="radio" name="base[sex]" value="1" lay-ignore  <eq name="$userInfo.sex" value="1">checked="checked"</eq>/>
                    男
                    <input type="radio" name="base[sex]"  value="2" lay-ignore <eq name="$userInfo.sex" value="2">checked="checked"</eq>/>
                    女
                </td>
                <th>民族</th>

                <td> <input type="radio" name="base[nation]" value="1" lay-ignore <eq name="$userInfo.nation" value="1">checked="checked"</eq>/>
                    汉
                    <input type="radio" name="base[nation]"  value="2" lay-ignore <eq name="$userInfo.nation" value="2">checked="checked"</eq>/>其他</td>
            </tr>
            <tr>
                <th>手机</th>
                <td colspan="3"><input type="text" name="base[phone]" lay-verify="base[phone]" value="{$userInfo.phone}"/></td>
                <th>住址</th>
                <td colspan="3"><input type="text" name="base[address]" lay-verify="base[address]" value="{$userInfo.address}"/></td>
            </tr>
            <tr>
                <th style="height: 120px;">病史</th>
                <td colspan="7" style="height: 120px;"><textarea name="base[medical_history]" rows="" cols="" lay-verify="base[medical_history]">{$userInfo.medical_history}</textarea></td>
            </tr>
            <tr>
                <th style="height: 120px;">过敏史</th>
                <td colspan="7" style="height: 120px;"><textarea name="base[allergy_history]" rows="" cols="" lay-verify="base[allergy_history]">{$userInfo.allergy_history}</textarea></td>
            </tr>

                    </table>
                </td>
            </tr>

        <div>
            <input type="hidden" name="id" value="{$userInfo.id}">
            <div id="submit" lay-submit="" lay-filter="submit">提交</div>
        </div>
    </form>
    <div class="bgimg" style="width: 100%;height: 100%;z-index: 100;position: fixed;top: 0;display: none;overflow: scroll;"><img style="width: 90%;display: block;margin:auto;" src="" alt="" /></div>
</div>
<script src="__HST__/js/jquery-1.7.1.min.js"></script>
<script src="__HST__/layui/layui.js"></script>
<script>
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.verify({
            'base[name]': function(value){
                if($.trim(value) == ''){ return '请填写姓名';}
            }
            ,'base[age]': function(value){
                if(value < 1){ return '请填写年龄';}
                if(isNaN(value)){ return '请正确填写年龄'}
            }
            ,'base[phone]': [/^1[3578]\d{9}$/, '请填写手机号码']
            ,'base[address]': function(value){
                if($.trim(value) == ''){ return '请填写住址';}
            }
            ,'base[medical_history]': function(value){
                if($.trim(value) == ''){ return '病史没有写无';}
            }
            ,'base[allergy_history]': function(value){
                if($.trim(value) == ''){ return '过敏史没有写无';}
            }
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        form.on('submit(submit)', function(data){
            //$(':input').each(function(){

               // if($.trim($(this).val()) == '' || $.trim($(this).val()) == undefined){
               //      layer.msg('请输入'+$(this).parent().prev().html());
               //      return false;
               //  }else{
                    //layer.msg(JSON.stringify(data.field));
                    $.ajax({
                        url:"{:url('patient/edit')}",
                        data:data.field,
                        success:function(res){

                            layer.msg(res.msg);
                            location.href = "{:url('patient/index')}";

                        },
                        error:function(){
                            layer.msg('网络错误');
                        }
                    })
                    //$('form').submit();
                // }
            })

         //   console.log(JSON.stringify(data.field))
            return false;
       // });
    });
    //上传图片
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '/upload/' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $(".applypictures").append("<img class='apply_image' src='layui-upload-img'/>");
                    $(".layui-upload-list .apply_image").last().attr('src', result);
                    $('.apply_image').dblclick(function(){
                        //alert($(this).attr("src"))
                        $('.bgimg img').attr('src',$(this).attr("src"));
                        $('.bgimg').show();
                        $('.bgimg img').click(function(){
                            $('.bgimg').hide();
                        })
                    })
                });
            }
            ,done: function(res){
                //上传完毕回调
            }
            ,error: function(){
                //请求异常回调

            }
        });
    });

    $('.cell_check').click(function(){
        $('.project table').hide();
        $('#cell_check').show();
        $(this).css('background','#fce5c2').siblings().css('background','#ffffff');
    })
    $('.diabetes').click(function(){
        $('.project table').hide();
        $('#diabetes').show();
        $(this).css('background','#fce5c2').siblings().css('background','#ffffff');
    })



</script>
</body>
</html>